#ifndef ClientSession_H
#define ClientSession_H

#include <boost/asio.hpp>
#include <queue>
#include "SocketConnection.h"

namespace ENE
{

//!Session d'un client
class ClientSession : public SocketConnection
{
    public:
		typedef boost::function<void ( const boost::system::error_code& ) > ConnectCallback;

		ClientSession(boost::asio::io_service& ioService);

		/*!
		*	Connecte le client a un serveur distant
		*	\param	host	Adresse du serveur distant
		*	\param	port	Port du serveur distant
		*/
		void connect(const std::string& host, const std::string& port, ConnectCallback handler);
		
	private:
		//Connecte au serveur
		void doConnect(boost::asio::ip::tcp::resolver::iterator endpoint, ConnectCallback handler);

		//Connecte au serveur
		void handleConnect(const boost::system::error_code& error,
							boost::asio::ip::tcp::resolver::iterator endpoint_iterator, 
							ConnectCallback handler);

		//Trouve un adresse IP valide
		boost::asio::ip::tcp::resolver m_resolver;
};


}//namespace ENE

#endif // CHU_ClientSession_H
